<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>Thrift Javascript Test</title>

  <script src="lib/thrift.js"         type="text/javascript" charset="utf-8"></script>
  <script src="../jquery/IFaceLog.js" type="text/javascript" charset="utf-8"></script>
  <script src="../jquery/IFaceLog_types.js"       type="text/javascript" charset="utf-8"></script>

  <!-- jQuery -->
  <script src="https://cdn.bootcss.com/jquery/1.10.0/jquery.min.js"></script>


  <script>
    // 连接facelog XHR服务
    var transport = new Thrift.Transport("http://localhost:36411");
    var protocol  = new Thrift.Protocol(transport);
    var client    = new IFaceLogClient(protocol);

  </script>
</head>
<body>
  <h1 id="qunit-header">Thrift Javascript Test: </h1>
  <script>
    // 调用version接口方法
    client.version((res)=>{
      $('.hint-version').append('version:' + res ) 
    })
    // 调用versionInfo接口方法
    client.versionInfo((res)=>{
      $('.hint-versionInfo').append('versionInfo:' + JSON.stringify(res) ) 
    })
    // 调用applyRootToken接口方法
    client.applyRootToken("guyadong",false,res=>{
      $('.hint-token').append('applyRootToken:' + JSON.stringify(res))
      // 调用getRedisParameters接口方法
      client.getRedisParameters(res,_res=>{
        $('.hint-getRedisParameters').append('getRedisParameters:' + JSON.stringify(_res))
      })
      // 同步调用getRedisParameters接口方法
      // var param = client.getRedisParameters(res)
      // $('.hint-getRedisParameters').append('getRedisParameters:' + JSON.stringify(param))
    })
    // 调用getPerson接口方法
    // user id = 5
    client.getPerson(5,res=>{
      $('.hint-getPerson').append('getPerson:' + JSON.stringify(res))
    })
  </script>
  <div>
    RESPONSE:
    <p class="hint-version"></p>
    <p class="hint-versionInfo"></p>
    <p class="hint-token"></p>
    <p class="hint-getPerson"></p>
    <p class="hint-getRedisParameters"></p>
  </div>
</body>
</html>
